<?php
/**
 * DCRM Mobile Page
 *
 * This file is part of WEIPDCRM.
 * 
 * WEIPDCRM is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * WEIPDCRM is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 * 
 * You should have received a copy of the GNU Affero General Public License
 * along with WEIPDCRM.  If not, see <http://www.gnu.org/licenses/>.
 */

require_once('system/common.inc.php');

base_url();

// URL For Rewrite 
$rewrite_mod = get_option('rewrite_mod');
switch($rewrite_mod){
	case 3:
		$rewrite_url = array('public' => 'public-%d.html','search' => 'search-mfss.html','public_nohistory' => 'public/%d/nohistory', 'screenshot' => 'screenshot/%d', 'history' => 'history/%d', 'contact' => 'contact/%d', 'pcsection' => 'list-%d.html','mipublic' => 'list-pg-%d.html','mipcpage' => 'list-%1$d-pg-%2$d.html', 'report' => 'report/%d', 'report_support' => 'report/%1$d/%2$d', 'more' => 'more/%d', 'more_offset' => 'more/%1$d/%2$d', 'misc' => 'misc','down' => 'downloads.html');
		break;
	case 1:
	case 2:
	default:
		$rewrite_url = array('view' => 'index.php?method=view&amp;pid=%d', 'view_nohistory' => 'index.php?pid=%d&amp;addr=nohistory', 'screenshot' => 'index.php?method=screenshot&amp;pid=%d', 'history' => 'index.php?method=history&amp;pid=%d', 'contact' => 'index.php?method=contact&amp;pid=%d', 'section' => 'index.php?method=section&amp;pid=%d', 'report' => 'index.php?method=report&amp;pid=%d', 'report_support' => 'index.php?method=report&amp;pid=%1$d&amp;support=%2$d', 'more' => 'index.php?method=more&amp;pid=%d', 'more_offset' => 'index.php?method=more&amp;pid=%1$d&amp;offset=%2$d', 'misc' => 'misc.php');
		break;
}
function echo_rewrite_url($type, $variable1, $variable2=''){
	global $rewrite_url;
	echo SITE_URL;
	printf($rewrite_url[$type], $variable1, $variable2);
}

class_loader('Mobile_Detect');
$detect = new Mobile_Detect;
if(!$detect->isiOS()){
	if (DCRM_PCINDEX == 1) {
		header("Location: ".SITE_URL."favourite.php");
		exit();
	} else {
		$isCydia = false;
	}
} else {
	if (DCRM_MOBILE == 2) {
		if (!strpos($detect->getUserAgent(), 'Cydia')) {
			$isCydia = false;
		} else {
			$isCydia = true;
		}
	} else {
		exit('Access Denied');
	}
}
if (file_exists('Release')) {
	$release = file('Release');
	$release_origin = __('No Name');
	$release_mtime = filemtime('Release');
	$release_time = date('Y-m-d H:i:s',$release_mtime);
	foreach ($release as $line) {
		if(preg_match('#^Origin#', $line)) {
			$release_origin = trim(preg_replace("#^(.+):\\s*(.+)#","$2", $line));
		}
		if(preg_match("#^Description#", $line)) {
			$release_description = trim(preg_replace("#^(.+):\\s*(.+)#","$2", $line));
		}
	}
} else {
	$release_origin = __('Empty Page');
}
if (isset($_GET['pid'])) {
	if (ctype_digit($_GET['pid']) && intval($_GET['pid']) <= 10000) {
		function device_check(){
			global $detect;
			$device_type = array('iPhone', 'iPod', 'iPad');
			for ($i = 0; $i < count($device_type); $i++) {
				$check = $detect->version($device_type[$i]);
				if ($check !== false) {
					if (isset($_SERVER['HTTP_X_MACHINE'])) {
						$DEVICE = $_SERVER['HTTP_X_MACHINE'];
					} else {
						$DEVICE = 'Unknown';
					}
					$OS = str_replace('_', '.', $check);
					break;
				}
			}
			return array('DEVICE' => $DEVICE, 'OS' => $OS);
		}

		if (isset($_GET['method']) && $_GET['method'] == 'screenshot') {
			$index = 2;
			$title = __('View Screenshots');
		} elseif (isset($_GET['method']) && $_GET['method'] == 'report') {
			$device_info = device_check();
			if (!isset($_GET['support'])) {
				$index = 3;
			} else {
				if ($_GET['support'] == '1') {
					$support = 1;
				} elseif ($_GET['support'] == '2') {
					$support = 2;
				} elseif ($_GET['support'] == '3') {
					$support = 3;
				} else {
					$support = 0;
				}
				$index = 4;
			}
			$title = __('Report Problems');
		} elseif (isset($_GET['method']) && $_GET['method'] == 'history') {
			$index = 5;
			$title = __('Version History');
		} elseif (isset($_GET['method']) && $_GET['method'] == 'contact') {
			$index = 6;
			$title = __('Contact us');
		} elseif (isset($_GET['method']) && $_GET['method'] == 'pcsection') {
			$index = 7;
          $section = DB::fetch_first("SELECT `Name`, `Icon` FROM `".DCRM_CON_PREFIX."Sections` WHERE `ID` = '".(int)$_GET['pid']."'");
			$title = __(DB::real_escape_string($section['Name']));
		} elseif (isset($_GET['method']) && $_GET['method'] == 'more') {
			$index = 8;
			$section = DB::fetch_first("SELECT `Name`, `Icon` FROM `".DCRM_CON_PREFIX."Sections` WHERE `ID` = '".(int)$_GET['pid']."'");
			$q_name = DB::real_escape_string($section['Name']);
			if (isset($_GET['offset']) && !empty($_GET['offset']) && ctype_digit($_GET['offset'])) {
				$offset = intval($_GET['offset']);
			} else {
				$offset = 0;
			}
			$packages = DB::fetch_all("SELECT `ID`, `Name`, `Package` FROM `".DCRM_CON_PREFIX."Packages` WHERE (`Stat` = '1' AND `Section` = '".$q_name."') ORDER BY `ID` DESC LIMIT 10 OFFSET ".$offset);
			foreach($packages as $package){
				if(!empty($package)){
					if ($isCydia) { ?>
				<a href="cydia://package/<?php echo($package['Package']); ?>" target="_blank">
<?php					} else { ?>
				<li>
	<a href="<?php echo_rewrite_url('pc', $package['ID']);?>" class="app_icon" >
<?php					} ?>
	
    
<div class="desc" ><?php echo ($package['Description']);  ?></div>
</li>
<?php
				}
			}
			exit();
		} elseif (!isset($_GET['method']) || (isset($_GET['method']) && $_GET['method'] == 'public')) {
			$index = 1;
			$title = __('View Package');
			$package_id = (int)DB::real_escape_string($_GET['pid']);
			$package_info = DB::fetch_first("SELECT `Name`, `Version`, `Author`, `Package`, `Description`, `DownloadTimes`, `Multi`, `CreateStamp`, `Size`, `Installed-Size`, `Section`, `Homepage`, `Tag`, `Level`, `Price`, `Purchase_Link`, `Changelog`, `Changelog_Older_Shows`, `Video_Preview`, `System_Support`, `ScreenShots` FROM `".DCRM_CON_PREFIX."Packages` WHERE `ID` = '".$package_id."' LIMIT 1");
			if ($package_info) $title = $package_info['Name'];
		} else {
			httpinfo(405);
			exit();
		}
	} else {
		httpinfo(405);
		exit();
	}
} elseif (!isset($_GET['method'])) {
	$index = 0;
	$title = $release_origin;
} else {
	httpinfo(405);
	exit();
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<title>捐助排行榜</title>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<meta name="apple-mobile-web-app-title" content="<?php echo($release_origin); ?>" />
		<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
		<meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
		<meta name="HandheldFriendly" content="true" />
		<meta name="format-detection" content="telephone=no" />
		<meta name="robots" content="index, follow" />
		<link rel="stylesheet" href="./Cydia/menes2.min.css">
      <link rel="stylesheet" href="<?php echo(SITE_URL); ?>/ziyuan/boot.css">
		<link rel="stylesheet" href="./Cydia/scroll2.min.css">     
		<script src="./Cydia/user/fastclick.js" type="text/javascript"></script>
		<script src="./Cydia/user/menes.js" type="text/javascript"></script>
		<script src="./Cydia/user/cytyle.js" type="text/javascript"></script><!--<base target="_top">--><base href="." target="_top"><style type="text/css"> p, input[type="password"], input[type="text"], select { top: 0.051470588235294115em; } </style>
		<script src="./Cydia/user/jquery.min.js"></script>
      
 <?php
if (defined("AUTOFILL_SEO")) {
?>
		<meta name="title" content="<?php echo(AUTOFILL_SEO); ?>" />
<?php
}
if (!empty($release_description)) {
?>
		<meta name="description" content="<?php echo($title); ?> ™| 最简洁的中文源，简单整洁有序的Cydia源，提供实用的DEB包。" />
<?php
}
if (defined("AUTOFILL_KEYWORDS")) {
?>
		<meta name ="keywords" content="<?php echo(AUTOFILL_KEYWORDS); ?>" />
<?php
}
if ($isCydia) {
?>
		<base target="_blank">
<?php
} else {
?>
		<base target="_top">
<?php
}
?>  

</head>
	<body class="pinstripe">
            <panel>
     <div style="height:2px;width:100%">
        <div style="background-color:red;height:2px;width:0" id="progress"></div>
    </div>
    <panel class="left">
        <div style="margin:9px;padding:0 16px">
            <style type="text/css">
                .cytyle-flat #logo {
                    background-image: url("./CydiaIcon.png");
                    background-size: 58px 58px;
                    width: 58px
                }
            </style>        
            <div id="logo" style="position:absolute;display:inline-block;height:58px;vertical-align:middle" alt="Cydia Logo"></div>
            <p style="padding-top:8px;margin-left:70px;text-align:center;display:block;height:60px;text-rendering:optimizeLegibility">
            <span style="font-size:18px">欢迎使用<?php echo(AUTOFILL_SEO); ?><sup>™</sup></span><br>
            <span style="font-size:14px"><a>捐助排行榜</a></span><br>
            <span style="font-size:14px"><a>Build by mycydia.vip</a></span></p>
        </div>


<?php
	$num = DB::result_first("SELECT count(*) FROM `".DCRM_CON_PREFIX."Activation` WHERE `Activation`='已使用'");
?>      
<block class="box1" style="background-color: #FFFFFF;">
<p style="color: #0000ff; font-size:14px;text-align:left;">我们是一群苹果手机爱好者，通过互联网结识，我们有一个共同的特点--我们都是年轻人--我们热爱分享和交流如果你觉得<?php echo(AUTOFILL_SEO); ?>的小东西对您有所帮助，请购买我们的VIP会员进行捐助
你的捐助能帮助我们更好的折腾。
</p>
<p style="text-align:right;">&nbsp;<?php echo(AUTOFILL_SEO); ?>
</p>
<p style="text-align:right;">2018年9月24日</p>
       <hr>
       <p><span style="color: #008000;">点击下方按钮链接-捐助服务器运营</p>
    </block>
      		<fieldset class="box">          
              <?php                        
		if (DCRM_DIRECT_DOW4 == 2) {
?>

<!--购买连接修改这里-->
             
              
              <a href="http://mycydia.vip/" target="_blank">
				<img class="icon" src="<?php echo(SITE_URL); ?>/icon/sc.png">
				<div>
                      <div>
                         <label>
                             <p><span style="color: #ff0000;">感谢您的捐助与支持 → → →</p>
                           <span class="ui-btn3" style="float:right;"><span style="color: #808080;">进入</span></span>
                         </label>
                      </div>
                    </div>
	  </a> 
              
  <script language="javascript">
    function cookipost2(){
    	parent.location.href='<?php echo(htmlspecialchars(AUTOFILL_GOUMAICUSTOM)); ?>'; 
	}
  </script>          
              
<?php
        }                        
		if (DCRM_DIRECT_DOW4 == 1) {
?>
                  <a> 
                        <img class="icon" src="icon/gly.png">
                            <div>
                                <div>
                                    <label>
                                        <p>购买会员组</p><i onclick="cookipost2()" class="ui-btn3" style="color: #979797; float:right;">购买</i>
                                    </label>
                                </div>
                            </div>
                  </a>
              
  <script language="javascript">
    function cookipost2(){
    	alert('http://#') 
	}
  </script>      
            
<?php
        }
?>               
			</fieldset> 
  
       
 <fieldset class="box">
<?php  
          $ress = DB::query("SELECT * FROM `".DCRM_CON_PREFIX."Activation`ORDER BY `Level` DESC limit 1000");
		foreach($ress as $res){    
          $resss = DB::query("SELECT * FROM `".DCRM_CON_PREFIX."User` WHERE  `Openid`='".$res['OPENID']."' ORDER BY `ID` DESC limit 1");
		foreach($resss as $ress){ 
?>
      
                  <a>
                        <img class="icon" src="<?php echo $ress['Logo'] ?>" style="border-radius: 50%;box-shadow:0 0 1px #AAA;padding:1px;margin-right: 1px;">
                            <div>
                                <div>
                                      <label>
                                        <p>捐助用户：<?php echo $ress['User'] ?></p>
<?php
          $re1 = DB::query("SELECT * FROM `".DCRM_CON_PREFIX."Activation` WHERE `Openid`='".$res['OPENID']."'ORDER BY `Level` DESC limit 1");
		foreach($re1 as $re){       
?>                                        
                                        <i class="ui-btn3" style="color: #979797; float:right;">
                         <?php
                         if($re['Level']=='2'){echo '￥10元';}
                         if($re['Level']=='3'){echo '￥20元';}  
                         if($re['Level']=='4'){echo '￥30元';}       
                         if($re['Level']=='5'){echo '￥40元';}      
                         if($re['Level']=='6'){echo '￥50元';}       
                         if($re['Level']=='7'){echo '￥100元';}
                         ?></i>
<?php
	}
?>                                         
                                    </label>
                                </div>
                            </div>
                  </a>

        

<?php
	}

	}
?> 
</fieldset>


 	         <fieldset class="box">
				<a>
					<div>
						<div>
						<span style="font-size:14px;color:#E53333;"><strong>说明:</strong></span>
						<span style="font-size:14px;color:#303130;">您的捐助将尽数用于服务器维护上！</span>
						</div>
					</div>
				</a>
			</fieldset>
      

			<fieldset class="source box">
				<a href="<?php echo(SITE_URL); ?>">
					<img class="icon" src="./CydiaIcon.png" />
					<div>
						<div>
							<label>
								<p id="source-name">
									<?php echo(AUTOFILL_SEO); ?>
								</p>
							</label>
						</div>
					</div>
				</a>
				<div class="source-description" >
					<p><marquee scrollAmount=<?php echo(AUTOFILL_DESCRIPTION3); ?> width="98%"><span style="color:<?php echo(AUTOFILL_DESCRIPTION2); ?>"><?php echo( defined("AUTOFILL_DESCRIPTION1") ? htmlspecialchars(stripslashes(AUTOFILL_DESCRIPTION1)) : $null ); ?></marquee></p>
				</div>
			</fieldset>

			<footer id="footer">
				<p>
					<span class="source-name">Copyright © 2015 cydiavip </span>·
					<span id="section">版权所有 &copy; 2015-2018</span>
				</p>
			</footer>

     
      
      
      
      
      